// FIXME: FLAT: improve for flat

group { name: "e/gadman/popup";
   parts {
      part { name: "bg"; type: RECT;
         description { state: "default" 0.0;
            color_class: "/bg/normal/gadgets/pop";
         }
      }
      part { name: "e.swallow.content"; type: SWALLOW; clip_to: "clip";
         scale: 1;
         description { state: "default" 0.0;
            rel1.offset: 4 4;
            rel2.offset: -5 -5;
            offscale;
         }
      }
      part { name: "clip"; type: RECT;
         description { state: "default";
         }
      }
   }
}

group { name: "e/gadman/full_bg";
   parts {
      part { name: "bg"; type: RECT; mouse_events: 0;
         description { state: "default" 0.0;
            color: 255 255 255 0; // no cc
            color_class: "/dim/normal/gadgets/full-bg";
            visible: 0;
         }
         description { state: "visible" 0.0;
            color: 255 255 255 255; // no cc
         }
      }
      part { name: "custom_bg"; type: RECT; mouse_events: 0;
         description { state: "default" 0.0;
            color: 255 255 255 0; // no cc
            visible: 0;
         }
         description { state: "visible" 0.0;
            color: 255 255 255 255; // no cc
         }
      }
      part { name: "e.swallow.bg"; type: SWALLOW; mouse_events: 0;
         clip_to: "custom_bg";
         description { state: "default" 0.0;
         }
      }
      part { name: "grabber"; type: RECT;
         description { state: "default" 0.0;
            color: 0 0 0 0; // no cc
         }
      }
   }
   programs {
      program { signal: "e,state,visibility,show"; source: "e";
         action: STATE_SET "visible" 0.0;
         transition: DECELERATE 0.4 USE_DURATION_FACTOR 1;
         target: "bg";
      }
      program { signal: "e,state,visibility,show,now"; source: "e";
         action: STATE_SET "visible" 0.0;
         target: "bg";
      }
      program { signal: "e,state,visibility,hide"; source: "e";
         action: STATE_SET "default" 0.0;
         transition: DECELERATE 0.4 USE_DURATION_FACTOR 1;
         target: "bg";
         after: "hide_stop";
      }
      program { signal: "e,state,visibility,hide,now"; source: "e";
         action: STATE_SET "default" 0.0;
         target: "bg";
         after: "hide_stop";
      }
      program { signal: "e,state,visibility,show,custom"; source: "e";
         action: STATE_SET "visible" 0.0;
         transition: DECELERATE 0.4 USE_DURATION_FACTOR 1;
         target: "custom_bg";
      }
      program { signal: "e,state,visibility,show,custom,now"; source: "e";
         action: STATE_SET "visible" 0.0;
         target: "custom_bg";
      }
      program { signal: "e,state,visibility,hide,custom"; source: "e";
         action: STATE_SET "default" 0.0;
         transition: DECELERATE 0.4 USE_DURATION_FACTOR 1;
         target: "custom_bg";
         after: "hide_stop";
      }
      program { signal: "e,state,visibility,hide,custom,now"; source: "e";
         action: STATE_SET "default" 0.0;
         target: "custom_bg";
         after: "hide_stop";
      }
      program { name: "hide_stop";
         action: SIGNAL_EMIT "e,action,hide,stop" "";
      }
   }
}

group { name: "e/gadman/frame";
   parts {
      part { name: "e.swallow.content"; type: SWALLOW;
         scale: 1;
         description { state: "default" 0.0;
            rel1.offset: 4 4;
            rel2.offset: -5 -5;
            offscale;
         }
      }
   }
}

group { name: "e/gadman/control";
   images.image: "outline.png" COMP;
   images.image: "diagonal_stripes.png" COMP;
   parts {
      part { name: "pat"; mouse_events: 0;
         description { state: "default" 0.0;
            rel1.to: "base";
            rel1.offset: 1 1;
            rel2.offset: -2 -2;
            rel2.to: "base";
            image.normal: "diagonal_stripes.png";
            color_class: "/bg/normal/gadgets/control/base";
            TILED_PATTERN(240, 240)
         }
      }
      part { name: "base"; mouse_events: 0;
         description { state: "default" 0.0;
            image.normal: "outline.png";
            image.border: 4 4 4 4;
            image.middle: 0;
            fill.smooth: 0;
            color_class: "/bg/normal/gadgets/control/outline";
         }
         description { state: "active" 0.0;
            inherit: "default" 0.0;
            color_class: "/bg/selected/gadgets/control/outline";
         }
      }
      part { name: "av10"; mouse_events: 0;
         scale;
         description { state: "default" 0.0;
            align: 0.5 1.0;
            rel1.to: "resizev1";
            rel2.relative: 1.0 0.0;
            rel2.to: "resizev1";
            image.normal: "i-arrow-u";
            color_class: "/bg/selected/gadgets/control/arrow";
            visible: 0;
            FIXED_SIZE(15, 15)
         }
         description { state: "pulse0" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
         description { state: "pulse1" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            rel2.relative: 1.0 -5.0;
            color: 255 255 255 0; // no cc
         }
      }
      part { name: "av11"; mouse_events: 0;
         scale;
         description { state: "default" 0.0;
            align: 0.5 0.0;
            rel1.to: "resizev1";
            rel1.relative: 0.0 1.0;
            rel2.to: "resizev1";
            image.normal: "i-arrow-d";
            color_class: "/bg/selected/gadgets/control/arrow";
            visible: 0;
            FIXED_SIZE(15, 15)
         }
         description { state: "pulse0" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
         description { state: "pulse1" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            rel1.relative: 0.0 6.0;
            color: 255 255 255 0; // no cc
         }
      }
      part { name: "av20"; mouse_events: 0;
         scale;
         description { state: "default" 0.0;
            align: 0.5 1.0;
            rel1.to: "resizev2";
            rel2.relative: 1.0 0.0;
            rel2.to: "resizev2";
            image.normal: "i-arrow-u";
            color_class: "/bg/selected/gadgets/control/arrow";
            visible: 0;
            FIXED_SIZE(15, 15)
         }
         description { state: "pulse0" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
         description { state: "pulse1" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            rel2.relative: 1.0 -5.0;
            color: 255 255 255 0; // no cc
         }
      }
      part { name: "av21"; mouse_events: 0;
         scale;
         description { state: "default" 0.0;
            align: 0.5 0.0;
            rel1.to: "resizev2";
            rel1.relative: 0.0 1.0;
            rel2.to: "resizev2";
            image.normal: "i-arrow-d";
            color_class: "/bg/selected/gadgets/control/arrow";
            visible: 0;
            FIXED_SIZE(15, 15)
         }
         description { state: "pulse0" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
         description { state: "pulse1" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            rel1.relative: 0.0 6.0;
            color: 255 255 255 0; // no cc
         }
      }
      part { name: "ah10"; mouse_events: 0;
         scale;
         description { state: "default" 0.0;
            align: 1.0 0.5;
            rel1.to: "resizeh1";
            rel2.relative: 0.0 1.0;
            rel2.to: "resizeh1";
            image.normal: "i-arrow-l";
            color_class: "/bg/selected/gadgets/control/arrow";
            visible: 0;
            FIXED_SIZE(15, 15)
         }
         description { state: "pulse0" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
         description { state: "pulse1" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            rel2.relative: -5.0 1.0;
            color: 255 255 255 0; // no cc
         }
      }
      part { name: "ah11"; mouse_events: 0;
         scale;
         description { state: "default" 0.0;
            align: 0.0 0.5;
            rel1.to: "resizeh1";
            rel1.relative: 1.0 0.0;
            rel2.to: "resizeh1";
            image.normal: "i-arrow-r";
            color_class: "/bg/selected/gadgets/control/arrow";
            visible: 0;
            FIXED_SIZE(15, 15)
         }
         description { state: "pulse0" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
         description { state: "pulse1" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            rel1.relative: 6.0 0.0;
            color: 255 255 255 0; // no cc
         }
      }
      part { name: "ah20"; mouse_events: 0;
         scale;
         description { state: "default" 0.0;
            align: 1.0 0.5;
            rel1.to: "resizeh2";
            rel2.relative: 0.0 1.0;
            rel2.to: "resizeh2";
            image.normal: "i-arrow-l";
            color_class: "/bg/selected/gadgets/control/arrow";
            visible: 0;
            FIXED_SIZE(15, 15)
         }
         description { state: "pulse0" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
         description { state: "pulse1" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            rel2.relative: -5.0 1.0;
            color: 255 255 255 0; // no cc
         }
      }
      part { name: "ah21"; mouse_events: 0;
         scale;
         description { state: "default" 0.0;
            align: 0.0 0.5;
            rel1.to: "resizeh2";
            rel1.relative: 1.0 0.0;
            rel2.to: "resizeh2";
            image.normal: "i-arrow-r";
            color_class: "/bg/selected/gadgets/control/arrow";
            visible: 0;
            FIXED_SIZE(15, 15)
         }
         description { state: "pulse0" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
         description { state: "pulse1" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            rel1.relative: 6.0 0.0;
            color: 255 255 255 0; // no cc
         }
      }
      part { name: "move"; type: RECT;
         description { state: "default" 0.0;
            rel1.to: "base";
            rel2.to: "base";
            color: 0 0 0 0; // no cc
         }
         description { state: "off" 0.0;
            inherit: "default" 0.0;
            visible: 0;
         }
      }
      part { name: "resizev1"; type: RECT;
         description { state: "default" 0.0;
            rel1.to: "base";
            rel2.to: "base";
            rel2.relative: 1.0 0.5;
            align: 0.5 0.0;
            max: 99999 7;
            color: 0 0 0 0; // no cc
         }
         description { state: "off" 0.0;
            inherit: "default" 0.0;
            visible: 0;
         }
      }
      part { name: "resizev2"; type: RECT;
         description { state: "default" 0.0;
            rel1.to: "base";
            rel2.to: "base";
            rel1.relative: 0.0 0.5;
            align: 0.5 1.0;
            max: 99999 7;
            color: 0 0 0 0; // no cc
         }
         description { state: "off" 0.0;
            inherit: "default" 0.0;
            visible: 0;
         }
      }
      part { name: "resizeh1"; type: RECT;
         description { state: "default" 0.0;
            rel1.to: "base";
            rel2.to: "base";
            rel2.relative: 0.5 1.0;
            align: 0.0 0.5;
            max: 7 99999;
            color: 0 0 0 0; // no cc
         }
         description { state: "off" 0.0;
            inherit: "default" 0.0;
            visible: 0;
         }
      }
      part { name: "resizeh2"; type: RECT;
         description { state: "default" 0.0;
            rel1.to: "base";
            rel2.to: "base";
            rel1.relative: 0.5 0.0;
            align: 1.0 0.5;
            max: 7 99999;
            color: 0 0 0 0; // no cc
         }
         description { state: "off" 0.0;
            inherit: "default" 0.0;
            visible: 0;
         }
      }
   }
   programs {
      program { signal: "e,state,hsize,on"; source: "e";
         action: STATE_SET "default" 0.0;
         target: "resizeh1";
         target: "resizeh2";
      }
      program { signal: "e,state,hsize,off"; source: "e";
         action: STATE_SET "off" 0.0;
         target: "resizeh1";
         target: "resizeh2";
      }
      program { signal: "e,state,vsize,on"; source: "e";
         action: STATE_SET "default" 0.0;
         target: "resizev1";
         target: "resizev2";
      }
      program { signal: "e,state,vsize,off"; source: "e";
         action: STATE_SET "off" 0.0;
         target: "resizev1";
         target: "resizev2";
      }
      program { signal: "e,state,move,on"; source: "e";
         action: STATE_SET "default" 0.0;
         target: "move";
      }
      program { signal: "e,state,move,off"; source: "e";
         action: STATE_SET "off" 0.0;
         target: "move";
      }
      program { signal: "e,state,focused"; source: "e";
         action: STATE_SET "active" 0.0;
         target: "base";
      }
      program { signal: "e,state,unfocused"; source: "e";
         action: STATE_SET "default" 0.0;
         target: "base";
      }
#define ARROWPULSE(_NAME, _SRC, _DST1, _DST2) \
      program { name: _NAME"0"; \
         signal: "mouse,in"; source: _SRC; \
         action: STATE_SET "pulse0" 0.0; \
         target: _DST1; \
         target: _DST2; \
         after: _NAME"1"; \
      } \
      program { name: _NAME"1"; \
         action: STATE_SET "pulse1" 0.0; \
         transition: DECELERATE 0.5; \
         target: _DST1; \
         target: _DST2; \
         after: _NAME"2"; \
      } \
      program { name: _NAME"2"; \
         action: STATE_SET "pulse0" 0.0; \
         target: _DST1; \
         target: _DST2; \
         after: _NAME"1"; \
      } \
      program { signal: "mouse,out"; source: _SRC; \
         action: ACTION_STOP; \
         target: _NAME"0"; \
         target: _NAME"1"; \
         target: _NAME"2"; \
         after: _NAME"3"; \
      } \
      program { name: _NAME"3"; \
         action: STATE_SET "default" 0.0; \
         target: _DST1; \
         target: _DST2; \
      }
      ARROWPULSE("pulse1", "resizev1", "av10", "av11")
      ARROWPULSE("pulse2", "resizev2", "av20", "av21")
      ARROWPULSE("pulse3", "resizeh1", "ah10", "ah11")
      ARROWPULSE("pulse4", "resizeh2", "ah20", "ah21")
#undef ARROWPULSE
#define PROGSET(_SRC, _ACT) \
      program { signal: "mouse,down,1"; source: _SRC; \
         action: SIGNAL_EMIT "e,action,"_ACT",start" ""; \
      } \
      program { signal: "mouse,up,1"; source: _SRC; \
         action: SIGNAL_EMIT "e,action,"_ACT",stop" ""; \
      } \
      program { signal: "mouse,move"; source: _SRC; \
         action: SIGNAL_EMIT "e,action,"_ACT",go"  ""; \
      }
      PROGSET("move", "move")
      PROGSET("resizev1", "resize,up")
      PROGSET("resizev2", "resize,down")
      PROGSET("resizeh1", "resize,left")
      PROGSET("resizeh2", "resize,right")
#undef PROGSET
   }
}
